import request from '@/router/axios';

/**
 * 部门列表
 * @param {String} parentId 父级id
 * @param {Object} params 条件
 */
export const getLazyList = (parentId, params) => {
  return request({
    url: '/system/dept/lazy-list',
    method: 'get',
    params: {
      ...params,
      parentId
    }
  })
}

/**
 * 删除指定部门
 * @param {String} ids 部门id，多个用逗号分隔
 */
export const remove = (ids) => {
  return request({
    url: '/system/dept/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/system/dept/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/system/dept/submit',
    method: 'post',
    data: row
  })
}

/**
 * 部门详情
 * @param {String} id 部门id 
 */
export const getDept = (id) => {
  return request({
    url: '/system/dept/detail',
    method: 'get',
    params: {
      id,
    }
  })
}

/**
 * 获取部门完整树结构
 */
export const getDeptTree = () => {
  return request({
    url: '/system/dept/tree',
    method: 'get',
  })
}

/**
 * 部门树节点
 * @param {String} parentId 父级id
 */
export const getDeptLazyTree = (parentId) => {
  return request({
    url: '/system/dept/lazy-tree',
    method: 'get',
    params: {
      parentId
    }
  })
}

